﻿/*
 * @author: wizardc
 */

using System.IO;
using UnityEditor;
using UnityEngine;

namespace DouEditor.Resource
{
    /// <summary>
    /// 打包全局设置
    /// </summary>
    public class BuildSetting : ScriptableObject
    {
        public static BuildSetting LoadSetting()
        {
            if (!File.Exists(AssetBundleBuildUtil.SettingPath))
            {
                var buildSetting = ScriptableObject.CreateInstance<BuildSetting>();
                AssetDatabase.CreateAsset(buildSetting, AssetBundleBuildUtil.SettingPath);
            }
            return AssetDatabase.LoadAssetAtPath<BuildSetting>(AssetBundleBuildUtil.SettingPath);
        }

        public static void SaveSetting(BuildSetting buildSetting)
        {
            EditorUtility.SetDirty(buildSetting);
            AssetDatabase.SaveAssetIfDirty(buildSetting);
        }

        /// <summary>
        /// 当前编辑器运行使用的打包规则
        /// </summary>
        public string editorUseBuildRule;
    }
}
